package com.qf.controller;

import com.qf.dao.UserDao;
import com.qf.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author Wy
 * @version V1.0
 * @Project MavenDemo
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/6/30 21:01
 */
@RestController
public class HelloController {

    @Resource(name = "user1")
    private User user;

    @Value("${alibaba.ip}")
    private  String ip;

    @Value("${alibaba.username}")
    private  String name;
    @Autowired
   private UserDao userDao;

    @RequestMapping("/hello")
    public String hello(){
        System.out.println(user);
        System.out.println(name);
        System.out.println(ip);


        return  "欢迎";
    }

    @PostMapping("/delete")
    public  String delete(Integer id){
        int delete = userDao.delete(id);

        return  null;
    }

    @GetMapping("/list")
    public  Object findAll(){
        List<User> all = userDao.findAll();
        return  all;
    }

    @PostMapping("/addUser")
    public  Object addUser(@RequestBody User user){

        int i = userDao.addUser(user);

        return  i;
    }

    @PostMapping("/update")
    public  Object update(@RequestBody User user){
        int update = userDao.update(user);
        return  update;
    }
}
